home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / comm / bbs / wwbbs31_source.lha / WWBBS / WWBBSSrc / console.c next >
C/C++ Source or Header  |  1995-06-26  |  19KB  |  479 lines

  1. #include <exec/types.h>
  2. #include <exec/exec.h>
  3. #include <intuition/intuition.h>
  4. #include <libraries/gadtools.h>
  5. #include <libraries/wwbbs.h>
  6. #include <devices/console.h>
  7. #include <devices/conunit.h>
  8. #include <ctype.h>
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12.  
  13. #include "wwbbs.h"
  14.  
  15. #include "wwbbs_settings.h"
  16.  
  17. #include "wwbbs_lib.h"
  18.  
  19. #include "libs.h"
  20.  
  21. #include "Data:Programs/Include/wwbbs_commands.h"
  22.  
  23. LONG __saveds ConsoleProc()
  24.     {
  25.         UWORD console_pens[]={ 0,7,7,7,4,5,0,0,7,(UWORD) ~0 };
  26.         struct NewMenu console_menu[]={
  27.             {NM_TITLE,"Project",0,0,0,0},
  28.             {NM_ITEM,"Quit","Q",0,0,0},
  29.             {NM_END,NULL,0,0,0,0}
  30.         };
  31.         struct ConfirmationMessage *msg;
  32.         struct CommandMessage *qmsg=NULL;
  33.         struct Process *proc;
  34.         proc=(struct Process *) FindTask(NULL);
  35.         WaitPort(&proc->pr_MsgPort);
  36.         if(msg=(struct ConfirmationMessage *) GetMsg(&proc->pr_MsgPort))
  37.             {
  38.                 BYTE name[64],command_name[64],id[33];
  39.                 struct MsgPort *port,*command_port;
  40.                 BOOL ok=TRUE;
  41.                 strcpy(id,msg->cm_ID);
  42.                 sprintf(name,"WWBBS Console.%s",id);
  43.                 if(!(port=CreatePort(name,0)))
  44.                     ok=FALSE;
  45.                 sprintf(command_name,"WWBBS Console Command.%s",id);
  46.                 if(!(command_port=CreatePort(command_name,0)))
  47.                     ok=FALSE;
  48.                 msg->cm_Return=ok;
  49.                 ReplyMsg((struct Message *) msg);
  50.                 if(ok)
  51.                     {
  52.                         struct Libraries *libs;
  53.                         if(libs=OpenLibraries())
  54.                             {
  55.                                 UBYTE node_type=NULL;
  56.                                 GetConfigTags(CFGTAG_Path,"Nodes",CFGTAG_Name,id,NDTAG_Type,&node_type,TAG_END);
  57.                                 {
  58.                                     struct Screen *Scr=NULL;
  59.                                     APTR VisualInfo;
  60.                                     struct Window *Win=NULL;
  61.                                     struct Menu *MenuStrip;
  62.                                     struct TextAttr fontta;
  63.                                     struct TextFont *font=NULL;
  64.                                     struct MsgPort *ConsoleReadMP=NULL,*ConsoleWriteMP;
  65.                                     struct IOStdReq *ConsoleReadIO,*ConsoleWriteIO;
  66.                                     struct CommandMessage *cmsg=NULL;
  67.                                     ULONG cdata=NULL;
  68.                                     ULONG mask;
  69.                                     BOOL kg=TRUE,consoleopen=FALSE;
  70.                                     BYTE con_read_buff[256],c;
  71.                                     while(kg)
  72.                                         {
  73.                                             {
  74.                                                 ULONG waitmask=NULL;
  75.                                                 waitmask|=1 << port->mp_SigBit;
  76.                                                 if(consoleopen)
  77.                                                     waitmask|=(1 << Win->UserPort->mp_SigBit) | (1 << ConsoleReadMP->mp_SigBit);
  78.                                                 if(cmsg)
  79.                                                     waitmask|=(1 << command_port->mp_SigBit);
  80.                                                 mask=Wait(waitmask);
  81.                                             }
  82.                                             if(mask & (1 << port->mp_SigBit))
  83.                                                 {
  84.                                                     struct CommandMessage *msg;
  85.                                                     ULONG data;
  86.                                                     while(kg && (msg=(struct CommandMessage *) GetMsg(port)))
  87.                                                         {
  88.                                                             data=msg->cm_Data;
  89.                                                             msg->cm_Data=NULL;
  90.                                                             switch(msg->cm_Command)
  91.                                                                 {
  92.                                                                     case CONCMD_Quit:
  93.                                                                         msg->cm_Data=TRUE;
  94.                                                                         qmsg=msg;
  95.                                                                         kg=FALSE;
  96.                                                                         break;
  97.                                                                     case CONCMD_Open:
  98.                                                                         if(consoleopen)
  99.                                                                             {
  100.                                                                                 ScreenToFront(Scr);
  101.                                                                                 ActivateWindow(Win);
  102.                                                                             }
  103.                                                                         else
  104.                                                                             {
  105.                                                                                 ULONG displaymode=INVALID_ID;
  106.                                                                                 Scr=NULL;
  107.                                                                                 VisualInfo=NULL;
  108.                                                                                 Win=NULL;
  109.                                                                                 MenuStrip=NULL;
  110.                                                                                 fontta.ta_Name=libs->Settings.font_name;
  111.                                                                                 fontta.ta_YSize=libs->Settings.font_ysize;
  112.                                                                                 fontta.ta_Style=NULL;
  113.                                                                                 fontta.ta_Flags=NULL;
  114.                                                                                 font=NULL;
  115.                                                                                 ConsoleReadMP=NULL;
  116.                                                                                 ConsoleWriteMP=NULL;
  117.                                                                                 ConsoleReadIO=NULL;
  118.                                                                                 ConsoleWriteIO=NULL;
  119.                                                                                 displaymode=libs->Settings.display_id;
  120.                                                                                 {
  121.                                                                                     if(displaymode==INVALID_ID)
  122.                                                                                         {
  123.                                                                                             struct Screen *scr;
  124.                                                                                             if(scr=LockPubScreen(NULL))
  125.                                                                                                 {
  126.                                                                                                     displaymode=GetVPModeID(&scr->ViewPort);
  127.                                                                                                     UnlockPubScreen(NULL,scr);
  128.                                                                                                 }
  129.                                                                                         }
  130.                                                                                 }
  131.                                                                                 if(displaymode!=INVALID_ID)
  132.                                                                                     {
  133.                                                                                         if(strlen(fontta.ta_Name) && fontta.ta_YSize)
  134.                                                                                             font=OpenDiskFont(&fontta);
  135.                                                                                         if(font)
  136.                                                                                             Scr=OpenScreenTags(NULL,SA_Depth,libs->Settings.display_depth,SA_DisplayID,displaymode,SA_Pens,console_pens,SA_DetailPen,0,SA_BlockPen,7,SA_Title,name,SA_PubName,name,SA_Font,&fontta,SA_Type,PUBLICSCREEN,SA_Interleaved,TRUE,TAG_END);
  137.                                                                                         else
  138.                                                                                             Scr=OpenScreenTags(NULL,SA_Depth,libs->Settings.display_depth,SA_DisplayID,displaymode,SA_Pens,console_pens,SA_DetailPen,0,SA_BlockPen,7,SA_Title,name,SA_PubName,name,SA_SysFont,0,SA_Type,PUBLICSCREEN,SA_Interleaved,TRUE,TAG_END);
  139.                                                                                         if(Scr)
  140.                                                                                             {
  141.                                                                                                 SetRGB4(&Scr->ViewPort,0,0,0,0); /* Black */ 
  142.                                                                                                 SetRGB4(&Scr->ViewPort,1,10,0,0); /* Red */
  143.                                                                                                 SetRGB4(&Scr->ViewPort,2,0,10,0); /* Green */
  144.                                                                                                 SetRGB4(&Scr->ViewPort,3,10,6,0); /* Yellow */
  145.                                                                                                 SetRGB4(&Scr->ViewPort,4,0,0,10); /* Blue */
  146.                                                                                                 SetRGB4(&Scr->ViewPort,5,10,0,10); /* Magenta */
  147.                                                                                                 SetRGB4(&Scr->ViewPort,6,0,10,10); /* Cyan */
  148.                                                                                                 SetRGB4(&Scr->ViewPort,7,10,10,10); /* White */
  149.                                                                                                 if(libs->Settings.display_depth==4)
  150.                                                                                                     {
  151.                                                                                                         SetRGB4(&Scr->ViewPort,8,6,6,6);
  152.                                                                                                         SetRGB4(&Scr->ViewPort,9,15,0,0);
  153.                                                                                                         SetRGB4(&Scr->ViewPort,10,0,15,0);
  154.                                                                                                         SetRGB4(&Scr->ViewPort,11,15,15,0);
  155.                                                                                                         SetRGB4(&Scr->ViewPort,12,0,0,15);
  156.                                                                                                         SetRGB4(&Scr->ViewPort,13,15,0,15);
  157.                                                                                                         SetRGB4(&Scr->ViewPort,14,0,15,15);
  158.                                                                                                         SetRGB4(&Scr->ViewPort,15,15,15,15);
  159.                                                                                                     }
  160.                                                                                                 if(VisualInfo=GetVisualInfo(Scr,TAG_END))
  161.                                                                                                     {
  162.                                                                                                         if(Win=OpenWindowTags(NULL,WA_Left,0,WA_Top,Scr->BarHeight+2,WA_Width,Scr->Width,WA_Height,Scr->Height-Scr->BarHeight-2,WA_IDCMP,IDCMP_MENUPICK,WA_PubScreen,Scr,WA_Flags,WFLG_NOCAREREFRESH|WFLG_BORDERLESS|WFLG_BACKDROP|WFLG_ACTIVATE|WFLG_SMART_REFRESH|WFLG_NEWLOOKMENUS,TAG_END))
  163.                                                                                                             {
  164.                                                                                                                 if( (MenuStrip=CreateMenus(console_menu,TAG_END)) && LayoutMenus(MenuStrip,VisualInfo,GTMN_NewLookMenus,TRUE,TAG_END) && SetMenuStrip(Win,MenuStrip) )
  165.                                                                                                                     {
  166.                                                                                                                         if( (ConsoleReadMP=CreateMsgPort()) && (ConsoleWriteMP=CreateMsgPort()) && (ConsoleReadIO=CreateIORequest(ConsoleReadMP,sizeof(struct IOStdReq))) && (ConsoleWriteIO=CreateIORequest(ConsoleWriteMP,sizeof(struct IOStdReq))) )
  167.                                                                                                                             {
  168.                                                                                                                                 ConsoleWriteIO->io_Data=Win;
  169.                                                                                                                                 ConsoleWriteIO->io_Length=sizeof(struct Window);
  170.                                                                                                                                 if(!OpenDevice("console.device",CONU_STANDARD,(struct IORequest *) ConsoleWriteIO,CONFLAG_DEFAULT))
  171.                                                                                                                                     {
  172.                                                                                                                                         ConsoleReadIO->io_Device=ConsoleWriteIO->io_Device;
  173.                                                                                                                                         ConsoleReadIO->io_Unit=ConsoleWriteIO->io_Unit;
  174.                                                                                                                                         PubScreenStatus(Scr,NULL);
  175.                                                                                                                                         {
  176.                                                                                                                                             strcpy(con_read_buff,"");
  177.                                                                                                                                             ConsoleReadIO->io_Data=&c;
  178.                                                                                                                                             ConsoleReadIO->io_Length=1;
  179.                                                                                                                                             ConsoleReadIO->io_Command=CMD_READ;
  180.                                                                                                                                             SendIO((struct IORequest *) ConsoleReadIO);
  181.                                                                                                                                         }
  182.                                                                                                                                         msg->cm_Data=TRUE;
  183.                                                                                                                                         consoleopen=TRUE;
  184.                                                                                                                                         SetStatusTags(STTAG_Name,id,STTAG_ConsoleOpen,TRUE,TAG_END);
  185.                                                                                                                                     }
  186.                                                                                                                             }
  187.                                                                                                                     }
  188.                                                                                                             }
  189.                                                                                                     }
  190.                                                                                             }
  191.                                                                                     }
  192.                                                                                 if(!consoleopen)
  193.                                                                                     {
  194.                                                                                         if(ConsoleWriteIO) DeleteIORequest(ConsoleWriteIO);
  195.                                                                                         if(ConsoleReadIO) DeleteIORequest(ConsoleReadIO);
  196.                                                                                         if(ConsoleWriteMP) DeleteMsgPort(ConsoleWriteMP);
  197.                                                                                         if(ConsoleReadMP) DeleteMsgPort(ConsoleReadMP);
  198.                                                                                         if(MenuStrip) { ClearMenuStrip(Win); FreeMenus(MenuStrip); }
  199.                                                                                         if(Win) CloseWindow(Win);
  200.                                                                                         if(VisualInfo) FreeVisualInfo(VisualInfo);
  201.                                                                                         if(Scr) CloseScreen(Scr);
  202.                                                                                         if(font) CloseFont(font);
  203.                                                                                     }
  204.                                                                             }
  205.                                                                         break;
  206.                                                                     case CONCMD_Close:
  207.                                                                         if(consoleopen)
  208.                                                                             {
  209.                                                                                 if(cmsg)
  210.                                                                                     {
  211.                                                                                         ReplyMsg((struct Message *) cmsg);
  212.                                                                                         cmsg=NULL;
  213.                                                                                     }
  214.                                                                                 if(!CheckIO((struct IORequest *) ConsoleReadIO))
  215.                                                                                     {
  216.                                                                                         AbortIO((struct IORequest *) ConsoleReadIO);
  217.                                                                                         WaitIO((struct IORequest *) ConsoleReadIO);
  218.                                                                                     }
  219.                                                                                 CloseDevice((struct IORequest *) ConsoleWriteIO);
  220.                                                                                 DeleteIORequest(ConsoleWriteIO);
  221.                                                                                 DeleteIORequest(ConsoleReadIO);
  222.                                                                                 DeleteMsgPort(ConsoleWriteMP);
  223.                                                                                 DeleteMsgPort(ConsoleReadMP);
  224.                                                                                 ClearMenuStrip(Win);
  225.                                                                                 FreeMenus(MenuStrip);
  226.                                                                                 CloseWindow(Win);
  227.                                                                                 FreeVisualInfo(VisualInfo);
  228.                                                                                 {
  229.                                                                                     struct EasyStruct es={ sizeof(struct EasyStruct),NULL,"WWBBS Console Request","Unable to close screen.\nPlease close all visitor windows.","Retry" };
  230.                                                                                     while(!CloseScreen(Scr))
  231.                                                                                         EasyRequest(NULL,&es,NULL);
  232.                                                                                 }
  233.                                                                                 if(font) CloseFont(font);
  234.                                                                                 consoleopen=FALSE;
  235.                                                                                 SetStatusTags(STTAG_Name,id,STTAG_ConsoleOpen,FALSE,TAG_END);
  236.                                                                             }
  237.                                                                         break;
  238.                                                                     case CONCMD_Read:
  239.                                                                         if(consoleopen && !cmsg)
  240.                                                                             {
  241.                                                                                 if(con_read_buff[0])
  242.                                                                                     {
  243.                                                                                         msg->cm_Data=con_read_buff[0];
  244.                                                                                         {
  245.                                                                                             char buff[256];
  246.                                                                                             strcpy(buff,&con_read_buff[1]);
  247.                                                                                             strcpy(con_read_buff,buff);
  248.                                                                                         }
  249.                                                                                     }
  250.                                                                             }
  251.                                                                         break;
  252.                                                                     case CONCMD_Write:
  253.                                                                         if(consoleopen && data)
  254.                                                                             {
  255.                                                                                 BYTE *buffer=NULL;
  256.                                                                                 ULONG size=0;
  257.                                                                                 {
  258.                                                                                     struct TagItem *tag;
  259.                                                                                     if(tag=FindTagItem(CONWRITETAG_Buffer,(struct TagItem *) data))
  260.                                                                                         buffer=(APTR) tag->ti_Data;
  261.                                                                                     if(tag=FindTagItem(CONWRITETAG_Size,(struct TagItem *) data))
  262.                                                                                         size=(ULONG) tag->ti_Data;
  263.                                                                                 }
  264.                                                                                 if(buffer && size)
  265.                                                                                     {
  266.                                                                                         ConsoleWriteIO->io_Data=buffer;
  267.                                                                                         ConsoleWriteIO->io_Length=size;
  268.                                                                                         ConsoleWriteIO->io_Command=CMD_WRITE;
  269.                                                                                         DoIO((struct IORequest *) ConsoleWriteIO);
  270.                                                                                         msg->cm_Data=TRUE;
  271.                                                                                     }
  272.                                                                             }
  273.                                                                         break;
  274.                                                                     case CONCMD_Wait:
  275.                                                                         if(consoleopen && !cmsg)
  276.                                                                             {
  277.                                                                                 if(con_read_buff[0])
  278.                                                                                     {
  279.                                                                                         msg->cm_Data=con_read_buff[0];
  280.                                                                                         {
  281.                                                                                             char buff[256];
  282.                                                                                             strcpy(buff,&con_read_buff[1]);
  283.                                                                                             strcpy(con_read_buff,buff);
  284.                                                                                         }
  285.                                                                                     }
  286.                                                                                 else
  287.                                                                                     {
  288.                                                                                         cmsg=msg;
  289.                                                                                         cdata=data;
  290.                                                                                     }
  291.                                                                             }
  292.                                                                         break;
  293.                                                                     case CONCMD_Abort:
  294.                                                                         if(consoleopen && cmsg)
  295.                                                                             {
  296.                                                                                 ReplyMsg((struct Message *) cmsg);
  297.                                                                                 cmsg=NULL;
  298.                                                                             }
  299.                                                                         break;
  300.                                                                     case CONCMD_Query:
  301.                                                                         if(consoleopen)
  302.                                                                             msg->cm_Data=strlen(con_read_buff);
  303.                                                                         break;
  304.                                                                 }
  305.                                                             if(!qmsg && cmsg!=msg)
  306.                                                                 ReplyMsg((struct Message *) msg);
  307.                                                         }
  308.                                                 }
  309.                                             if(consoleopen)
  310.                                                 {
  311.                                                     if(mask & (1 << Win->UserPort->mp_SigBit))
  312.                                                         {
  313.                                                             struct IntuiMessage *msg;
  314.                                                             ULONG class;
  315.                                                             UWORD code;
  316.                                                             BOOL kg2=TRUE;
  317.                                                             while(kg && kg2 && (msg=(struct IntuiMessage *) GetMsg(Win->UserPort)))
  318.                                                                 {
  319.                                                                     class=msg->Class;
  320.                                                                     code=msg->Code;
  321.                                                                     ReplyMsg((struct Message *) msg);
  322.                                                                     switch(class)
  323.                                                                         {
  324.                                                                             case IDCMP_MENUPICK:
  325.                                                                                 switch(MENUNUM(code))
  326.                                                                                     {
  327.                                                                                         case 0:
  328.                                                                                             switch(ITEMNUM(code))
  329.                                                                                                 {
  330.                                                                                                     case 0:
  331.                                                                                                         switch(node_type)
  332.                                                                                                             {
  333.                                                                                                                 case NDTYP_Local:
  334.                                                                                                                     SetStatusTags(STTAG_Name,id,STTAG_Panic,TRUE,TAG_END);
  335.                                                                                                                     if(cmsg)
  336.                                                                                                                         {
  337.                                                                                                                             ReplyMsg((struct Message *) cmsg);
  338.                                                                                                                             cmsg=NULL;
  339.                                                                                                                         }
  340.                                                                                                                     break;
  341.                                                                                                                 case NDTYP_Remote:
  342.                                                                                                                     if(consoleopen)
  343.                                                                                                                         {
  344.                                                                                                                             if(cmsg)
  345.                                                                                                                                 {
  346.                                                                                                                                     ReplyMsg((struct Message *) cmsg);
  347.                                                                                                                                     cmsg=NULL;
  348.                                                                                                                                 }
  349.                                                                                                                             if(!CheckIO((struct IORequest *) ConsoleReadIO))
  350.                                                                                                                                 {
  351.                                                                                                                                     AbortIO((struct IORequest *) ConsoleReadIO);
  352.                                                                                                                                     WaitIO((struct IORequest *) ConsoleReadIO);
  353.                                                                                                                                 }
  354.                                                                                                                             CloseDevice((struct IORequest *) ConsoleWriteIO);
  355.                                                                                                                             DeleteIORequest(ConsoleWriteIO);
  356.                                                                                                                             DeleteIORequest(ConsoleReadIO);
  357.                                                                                                                             DeleteMsgPort(ConsoleWriteMP);
  358.                                                                                                                             DeleteMsgPort(ConsoleReadMP);
  359.                                                                                                                             ClearMenuStrip(Win);
  360.                                                                                                                             FreeMenus(MenuStrip);
  361.                                                                                                                             CloseWindow(Win);
  362.                                                                                                                             FreeVisualInfo(VisualInfo);
  363.                                                                                                                             {
  364.                                                                                                                                 struct EasyStruct es={ sizeof(struct EasyStruct),NULL,"WWBBS Console Request","Unable to close screen.\nPlease close all visitor windows.","Retry" };
  365.                                                                                                                                 while(!CloseScreen(Scr))
  366.                                                                                                                                     EasyRequest(NULL,&es,NULL);
  367.                                                                                                                             }
  368.                                                                                                                             if(font) CloseFont(font);
  369.                                                                                                                             consoleopen=FALSE;
  370.                                                                                                                             SetStatusTags(STTAG_Name,id,STTAG_ConsoleOpen,FALSE,TAG_END);
  371.                                                                                                                         }
  372.                                                                                                                     kg2=FALSE;
  373.                                                                                                                     break;
  374.                                                                                                             }
  375.                                                                                                         break;
  376.                                                                                                 }
  377.                                                                                             break;
  378.                                                                                     }
  379.                                                                                 break;
  380.                                                                         }
  381.                                                                 }
  382.                                                         }
  383.                                                     if(mask & (1 << command_port->mp_SigBit))
  384.                                                         {
  385.                                                             struct CommandMessage *msg;
  386.                                                             ULONG data;
  387.                                                             while(msg=(struct CommandMessage *) GetMsg(command_port))
  388.                                                                 {
  389.                                                                     data=msg->cm_Data;
  390.                                                                     msg->cm_Data=NULL;
  391.                                                                     switch(msg->cm_Command)
  392.                                                                         {
  393.                                                                             case NDCMD_Quit:
  394.                                                                                 SetStatusTags(STTAG_Name,id,STTAG_Panic,TRUE,TAG_END);
  395.                                                                                 break;
  396.                                                                             case NDCMD_Panic:
  397.                                                                                 SetStatusTags(STTAG_Name,id,STTAG_Panic,TRUE,TAG_END);
  398.                                                                                 msg->cm_Data=TRUE;
  399.                                                                                 break;
  400.                                                                             case NDCMD_Page:
  401.                                                                                 break;
  402.                                                                         }
  403.                                                                     ReplyMsg((struct Message *) msg);
  404.                                                                 }
  405.                                                             if(cmsg)
  406.                                                                 {
  407.                                                                     ReplyMsg((struct Message *) cmsg);
  408.                                                                     cmsg=NULL;
  409.                                                                 }
  410.                                                         }
  411.                                                 }
  412.                                             if(consoleopen)
  413.                                                 {
  414.                                                     if(mask & (1 << ConsoleReadMP->mp_SigBit))
  415.                                                         {
  416.                                                             WaitIO((struct IORequest *) ConsoleReadIO);
  417.                                                             if(cmsg)
  418.                                                                 {
  419.                                                                     cmsg->cm_Data=c;
  420.                                                                     ReplyMsg((struct Message *) cmsg);
  421.                                                                     cmsg=NULL;
  422.                                                                 }
  423.                                                             else
  424.                                                                 {
  425.                                                                     if(strlen(con_read_buff)<=255)
  426.                                                                         strncat(con_read_buff,&c,1);
  427.                                                                 }
  428.                                                             {
  429.                                                                 ConsoleReadIO->io_Data=&c;
  430.                                                                 ConsoleReadIO->io_Length=1;
  431.                                                                 ConsoleReadIO->io_Command=CMD_READ;
  432.                                                                 SendIO((struct IORequest *) ConsoleReadIO);
  433.                                                             }
  434.                                                         }
  435.                                                 }
  436.                                         }
  437.                                     if(consoleopen)
  438.                                         {
  439.                                             if(cmsg)
  440.                                                 {
  441.                                                     ReplyMsg((struct Message *) cmsg);
  442.                                                     cmsg=NULL;
  443.                                                 }
  444.                                             if(!CheckIO((struct IORequest *) ConsoleReadIO))
  445.                                                 {
  446.                                                     AbortIO((struct IORequest *) ConsoleReadIO);
  447.                                                     WaitIO((struct IORequest *) ConsoleReadIO);
  448.                                                 }
  449.                                             CloseDevice((struct IORequest *) ConsoleWriteIO);
  450.                                             DeleteIORequest(ConsoleWriteIO);
  451.                                             DeleteIORequest(ConsoleReadIO);
  452.                                             DeleteMsgPort(ConsoleWriteMP);
  453.                                             DeleteMsgPort(ConsoleReadMP);
  454.                                             ClearMenuStrip(Win);
  455.                                             FreeMenus(MenuStrip);
  456.                                             CloseWindow(Win);
  457.                                             FreeVisualInfo(VisualInfo);
  458.                                             {
  459.                                                 struct EasyStruct es={ sizeof(struct EasyStruct),NULL,"WWBBS Console Request","Unable to close screen.\nPlease close all visitor windows.","Retry" };
  460.                                                 while(!CloseScreen(Scr))
  461.                                                     EasyRequest(NULL,&es,NULL);
  462.                                             }
  463.                                             if(font) CloseFont(font);
  464.                                         }
  465.                                 }
  466.                                 CloseLibraries(libs);
  467.                             }
  468.                     }
  469.                 if(command_port) DeletePort(command_port);
  470.                 if(port) DeletePort(port);
  471.             }
  472.         if(qmsg)
  473.             {
  474.                 Forbid();
  475.                 ReplyMsg((struct Message *) qmsg);
  476.             }
  477.         return(0);
  478.     }
  479.